#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        char c;
        double p;
        cin>>c>>p;
        if (c=='M')
            printf("%.2f\n",p/1.09);
        else if (c=='F')
            printf("%.2f\n",p*1.09);
    }
}